#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int extractCommand( const char sock_msg[1024], char *operator, char *operand ){
    char local_str[1024];
    sprintf(local_str, "%s", sock_msg);
    
    char *p;
    sprintf(operator, "%s", strtok(local_str, "|"));
    
    p = strtok(NULL, "|");
    sprintf(operand, "%s", p);
    
    return 0;
}


int main( int argc, char *argv[] ){
    if(argc !=2){
        printf("> usage: %s operator|operand\n", argv[0]);
        return 0;
    }
    
    char operator[128];
    char operand[128];
    
    if( extractCommand(argv[1], operator, operand) != 0 ){
        printf("> failed to extract operator and operand from input: %s\n", argv[1]);
        return 0;
    }
    
    printf("> operator: %s.\n", operator);
    printf("> operand:  %s.\n", operand);
}
